package com.cat.dynamicPlanning02;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/domino-and-tromino-tiling/
 * @create 2025/10/10 16:17
 * @since JDK17
 */

public class Solution17 {
    public int numTilings(int n) {
        long[] dp = new long[n + 1];
        int N = (int) (1e9 + 7);
        if (n == 1) {
            return 1;
        }
        if (n == 2) {
            return 2;
        }
        if (n == 3) {
            return 5;
        }
        dp[1] = 1;
        dp[2] = 2;
        dp[3] = 5;
        for (int i = 4; i <= n; i++) {
            dp[i] = (2 * dp[i - 1] + dp[i - 3]) % N;
        }
        return (int) dp[n];
    }
}
